/**
 * @summary 文章模块
 * @author yang
 */
import * as articleApi from '@/api/article'
export default {
  // 我是模块（namespaced: true）
  namespaced: true,
  state: {
    articleList: [],
    // 首页搜索文章点击进入详情页
    articleId: [],
  },
  mutations: {
    SET_ARTICLE_LIST(state, newValue) {
      state.articleList = newValue;
    },
    ARTICLE_ID(state, newValue) {
      state.articleId = newValue;
    },
  },
  actions: {
    async updatearticleList({ commit }, id) {
      const res = await articleApi.getArticleList(id);
      commit('SET_ARTICLE_LIST', res);
    },
    async updatearticleId({ commit }, id) {
      const res = await articleApi.getArticleId(id);
      commit('ARTICLE_ID', res);
      // console.log('111', res);
    }
  }
}
